home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0769A.ZIP / DTOS.PRG < prev    next >
Text File  |  1987-09-09  |  3KB  |  130 lines

  1. *:*********************************************************************
  2. *:
  3. *:      Program: DTOS.PRG
  4. *:
  5. *:       System: DTOS U.D.F. for Foxbase+ Ver. 2.0
  6. *:       Author: Tony Ray
  7. *:    Copyright (c) 1987, Tony Ray
  8. *:
  9. *: Documented: 9/9/87       17:04                   SNAP! version 2.02a
  10. *:*********************************************************************
  11.  
  12. ***************************************
  13. *    SEARCH can be used with DTOS
  14. *           in the prg. as follows:
  15. *
  16. *           mgo = search(mdate)
  17. *
  18. *           where:
  19. *           mdate is a date variable;
  20. *           mgo will be .T. if a record
  21. *           was found() and .F. if no
  22. *           record was found().
  23. *
  24. *           You can also use as search(ctod(mdate))
  25. *           when mdate is a char. var. as follows:
  26. *
  27. *        do while .t.
  28. *           mdate = (space(8)
  29. *           @ row, col say "Enter date (cr) to exit " ;
  30. *               get mdate pict "99/99/99"
  31. *           read
  32. *           clear gets
  33. *           if len(trim(mdate))=0
  34. *              exit
  35. *           endif
  36. *           if search(ctod(mdate))    && will be .t. if you found() a match
  37. *
  38. *              do something
  39. *
  40. *           else                      && if search(ctod(mdate)) is .f.
  41. *
  42. *
  43. *               @ row+1,col say "No records for that date, reenter"
  44. *           endif
  45. *        enddo
  46. ***************************************
  47. PROCEDURE search
  48. PARAMETER xdate
  49. xdate = DTOS(xdate)
  50. SEEK xdate
  51. IF FOUND()
  52.     RETURN .T.
  53. ELSE
  54.     RETURN .F.
  55.     
  56.     
  57.     ***************************************
  58.     *    DTOS takes a date variable and
  59.     *         converts it to a char. string
  60.     *         in the form 8708/31 ( from
  61.     *         08/31/87 ) to use with seek
  62.     *         when the database is indexed on
  63.     *         a date field plus a char. field, as follows:
  64.     *         SUBSTR(DTOC(<field>),7,2)+SUBSTR(DTOC(<field>),1,5) + chra. var.
  65.     *         (*plus* a char. variable.)  If you only index
  66.     *         on a date field with no char.
  67.     *         variables, you don't need this.
  68.     ***************************************
  69.     PROCEDURE DTOS
  70.     PARAMETER xdate
  71.     RETURN SUBSTR(DTOC(xdate),7,2)+SUBSTR(DTOC(xdate),1,5)
  72.     
  73.     
  74.     ***************************************
  75.     *    STOD takes the char string made by
  76.     *         DTOS and converts it back to
  77.     *         regular date memo. variable
  78.     *         (you don't need this unless you
  79.     *         have converted the variable to
  80.     *         a char. string)
  81.     ***************************************
  82.     PROCEDURE STOD
  83.     PARAMETER xdate
  84.     xdate = CTOD(SUBSTR(xdate,3,5)+"/"+SUBSTR(xdate,1,2))
  85.     RETURN xdate
  86.     
  87.     
  88.     
  89.     
  90.     
  91.     
  92.     ******************
  93.     *      clipper version
  94.     *      delete this or fox
  95.     *      version above
  96.     *
  97.     *      This seems to work in clipper
  98.     *      when the database is indexed
  99.     *      with dtos(date)+char.var.??
  100.     *
  101.     *******************
  102.     
  103.     
  104.     FUNCTION DTOS
  105.     PARAMETER xdate
  106.     RETURN(SUBSTR(DTOC(xdate),7,2)+SUBSTR(DTOC(xdate),1,5))
  107.     
  108.     
  109.     FUNCTION STOD
  110.     PARAMETER xdate
  111.     xdate = CTOD(SUBSTR(xdate,3,5)+"/"+SUBSTR(xdate,1,2))
  112.     RETURN(xdate)
  113.     
  114.     
  115.     
  116.     FUNCTION search
  117.     PARAMETER xdate
  118.     xdate = DTOS(xdate)
  119.     SEEK xdate
  120.     IF FOUND()
  121.         RETURN(.T.)
  122.     ELSE
  123.         RETURN(.F.)
  124.     ENDIF
  125.     
  126.     
  127.     *EOF DTOSclip
  128.     
  129. *: EOF: DTOS.PRG
  130.